﻿using System.Collections;
using System.Collections.Generic;
using LitJson;
using UnityEngine;

public class QueryChatListRequest : BaseRequest
{

	private ChatListPanel _chatListPanel;
	
	protected override void Awake()
	{
		_controllerType = ControllerType.USER;
		_methodType = MethodType.QUERY_CHAT_LIST;
		
		base.Awake();
	}

	/// <summary>
	/// 发送请求（无需数据域部分）
	/// </summary>
	public void SendRequest()
	{
		//该请求无需携带参数域，后端由SocketChannel来辨识
		NettyRequest nettyRequest = new NettyRequest();
		nettyRequest.controllerType = (int) _controllerType;
		nettyRequest.methodType = (int) _methodType;
		nettyRequest.data = "none";
		byte[] dataBytes = ConverterTool.SerialRequestObj(nettyRequest);
		UnityFacade.Instance.ClientManager.SendMsgToServer(dataBytes);
	}
	
	// Use this for initialization
	void Start () {
		//组件初始化
		_chatListPanel = this.gameObject.GetComponent<ChatListPanel>();
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
	
	public override void OnResponse(string data)
	{
		JsonData respJsonData = JsonMapper.ToObject(data);
		
		_chatListPanel.HandleResponse(respJsonData);
	}

	
}
